<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 验证0-255之间的数字 */
        // 个位(0-9) 十位(1-9)(0-9) 百位1(0-9)(0-9)|2(0-4)(0-9)|25(0-5)
        var reg = /^(\d|\d{2}|(1\d{2}|2([0-4])\d|25([0-5]))){1,}$/
        var str = '34'
        console.log(reg.test(str))
    </script>
</body>
</html>